package com.company.adapterMode;

/**
 * @description: 创建一个MediaPlayer的适配器, 使其能播放mp4 vlc格式的歌曲
 * @author: zgw
 * @create: 2020-12-07 16:17
 **/
public class MediaAdapter implements MediaPlayer{

    AdvancedMediaPlayer advancedMediaPlayer;

    public MediaAdapter(String audioType){
        if ("mp4".equals(audioType)){
            advancedMediaPlayer = new Mp4Player();
        }
        if ("vlc".equals(audioType)){
            advancedMediaPlayer = new VlcPlayer();
        }
    }

    @Override
    public void play(String audioType, String fileName) {
        if ("mp4".equals(audioType)){
            advancedMediaPlayer.playMp4(fileName);
        }
        if ("vlc".equals(audioType)){
            advancedMediaPlayer.playVlc(fileName);
        }
    }
}
